Generation apparatus, program, and generation method

ABSTRACT

A generation apparatus that generates a mapping between individual properties included in an object in a program and individual elements of a structured document. The generation apparatus includes: an object tree generation unit that generates a tree structure representing hierarchical structure of the object by assigning the individual properties included in the object to nodes of the tree structure; and a selection unit that selects a mapping minimizing conversion cost of converting the tree structure of the object to a tree structure that includes the individual elements of the structured document as its nodes. The selection is from mappings that associate the individual properties included in the object with the individual elements of the structured document.

BACKGROUND Field of the Invention

The present invention relates to an apparatus, a program, and a methodfor generating a mapping between individual properties included in anobject in a program and the individual elements of a structureddocument.

Description of Related Art

Methods for converting Extensible Markup Language (XML) documents toobjects handled by programs are known. “Document Object Model (DOM)Level 3 Core Specification,” Apr. 7, 2004, W3C discloses thespecifications of the Document Object Model (DOM) that is an applicationprogram interface for programs to access XML documents. “JSR 222: JavaArchitecture for XML Binding (JAXB) 2.0,” Java Community Processdiscloses the specifications of the Java Architecture for XML Binding(JAXB) that provides the facility of a schema compiler and a schemagenerator for converting XML documents to Java (registered trademark)objects and converting Java objects to XML documents.

Also, methods for converting an object in a program to an XML documenthave been known. For example, in the DOM reference described above, anXML document can be generated from an object in which the individualelements of a converted XML document are reflected in advance. In theJAXB reference described above, an XML schema can be automaticallygenerated from the class of a Java object, and an XML document cangenerated from the Java object on the basis of the automaticallygenerated XML schema.

“Castor XML Mapping,” ExoLab Group, Intalio Inc., and “JiBX: Binding XMLto Java Code,” Sosnoski Software Solutions Inc., disclose data bindingtools for performing mapping between XML documents and objects. Anyobject can be converted to an XML document using such tools or librariesor PHP (a programming language for hypertext processing) SOAP functions.

Japanese Unexamined Patent Application Publication No. 2003-256455discloses a method for converting XML documents to data models otherthan objects. Philip Bille, “A survey on tree edit distance and relatedproblems,” June 2005 discloses solutions to the tree editing problem,i.e., a problem of calculating the edit cost and procedure for obtainingthe same tree structure as a second tree structure by editing a firsttree structure.

The aforementioned processes for converting an object in a program to anXML document are complicated and often inconvenient for programmers. Forexample, in the DOM reference, unless an object in which the elements ofan XML document are accurately reflected is generated in advance using aprogram, conversion cannot be performed appropriately. In the JAXBreference, an object not being a class that was used to generate an XMLschema cannot be converted to an XML document. Even with the tools orlibraries described in the ExoLab Group and Sosnoski Software referencesor PHP SOAP functions, programmers need to describe correspondencesbetween the individual properties of an object of a program and theindividual elements of a structured document in advance. Moreover, suchdescription needs to be provided for the classes of all objects and theelements of all XML documents.

SUMMARY

A first aspect of the present invention provides a generation apparatusthat generates a mapping between individual properties included in anobject in a program and individual elements of a structured document.The generation apparatus includes an object tree generation unitconfigured to generate a tree structure representing hierarchicalstructure of the object by assigning the individual properties includedin the object to nodes of the tree structure; and a selection unitconfigured to select, from mappings that associate the individualproperties included in the object with the individual elements of thestructured document, a mapping minimizing conversion cost of convertingthe tree structure of the object to a tree structure that includes theindividual elements of the structured document as its nodes.

According to another aspect of the invention, a method for generating amapping between individual properties included in an object in a programand individual elements of a structured document includes the steps of:generating a tree structure representing hierarchical structure of theobject by assigning the individual properties included in the object tonodes of the tree structure; and selecting, a mapping minimizingconversion cost of converting the tree structure of the object to a treestructure that includes the individual elements of the structureddocument as its nodes, said selecting being from mappings that associatethe individual properties included in the object with the individualelements of the structured document.

A still further aspect of the invention provides computer programswhich, when executed, cause a computer to act as the generationapparatus or to perform the steps of the above method.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows the functional configuration of an information processingapparatus 10 according to an embodiment of the present invention.

FIG. 2 shows the functional configuration of a generation apparatus 20according to the embodiment of the present invention.

FIG. 3 shows the process flow of the generation apparatus 20.

FIG. 4 shows an exemplary process performed in step S104 in FIG. 3.

FIG. 5 shows an exemplary program written in PHP.

FIG. 6 exemplifies the properties of the object, which has beenconverted to a tree structure, in the program shown in FIG. 5 and therespective values of the properties, described in XML.

FIG. 7 exemplifies the properties of the object, which has beenconverted to a tree structure, in the program shown in FIG. 5 and therespective values of the properties, described schematically.

FIG. 8 shows exemplary WSDL that defines a Web service.

FIG. 9 shows an exemplary schema described in XML (an XML schema).

FIG. 10 shows the tree structure of an XML document defined by theschema shown in FIG. 9.

FIG. 11 shows an exemplary edit to convert the tree structure of theobject shown in FIG. 7 to the tree structure of the XML document shownin FIG. 10.

FIG. 12 shows exemplary description of a mandatory node, an optionalnode, and a repetitive node.

FIG. 13 shows an exemplary XML document that is converted from theobject shown in FIG. 5 on the basis of a mapping selected by theselection unit 42.

FIG. 14 shows an exemplary tree structure of an object that includes anarray.

FIG. 15 shows an exemplary tree structure of an XML document thatincludes repetitive elements.

FIG. 16A shows an exemplary tree structure obtained by removing thechild nodes of the array node from the tree structure of the objectshown in FIG. 14.

FIG. 16B shows an exemplary tree structure obtained by removing thechild nodes of the repetitive nodes from the tree structure of the XMLdocument shown in FIG. 15.

FIG. 17A shows an exemplary tree structure of a part on the low end sideof the tree structure of the object shown in FIG. 14, the top of thepart being one of the child nodes of the array node.

FIG. 17B shows an exemplary tree structure of a part on the low end sideof the tree structure of the XML document shown in FIG. 15, the top ofthe part being one of the repetitive nodes.

FIG. 18 shows an exemplary hardware configuration of a computer 1900according to the embodiment of the present invention.

DETAILED DESCRIPTION

FIG. 1 shows the functional configuration of an information processingapparatus 10 according to a preferred embodiment of the presentinvention. The information processing apparatus 10 is implemented via acomputer that executes a program. The information processing apparatus10 performs information processing provided by the program.

The information processing apparatus 10 can use a Web service providedby, for example, another computer in a network. In particular, theinformation processing apparatus 10 sends a SOAP message that includesan XML document to a Web service. The information processing apparatus10 receives a SOAP message that includes an XML document representingthe result of processing from the Web service to perform informationprocessing using the result of processing.

The information processing apparatus 10 includes a program processingunit 12, a schema storage unit 14, and a library processing unit 16. Theprogram processing unit 12 is implemented by execution of a program by acomputer. The schema storage unit 14 stores schemata that definerespective XML documents included in SOAP messages exchanged between theinformation processing apparatus 10 and Web services used by theinformation processing apparatus 10. The schema storage unit 14 isimplemented via a storage unit in a computer or a storage unit connectedto the computer through a network.

The library processing unit 16 exchanges SOAP messages that include XMLdocuments with predetermined Web services. The library processing unit16 is implemented by execution, by a computer, of programs in a librarycalled in response to function calls by the program processing unit 12.

In particular, the library processing unit 16 receives, from the programprocessing unit 12, a function call that includes an object as anargument. The library processing unit 16 converts the object to an XMLdocument based on an XML schema stored in the schema storage unit 14.The library processing unit 16 sends a SOAP message that includes thegenerated XML document to a Web service. The library processing unit 16receives, from the Web service, a SOAP message that includes the resultof processing expressed as an XML document. The library processing unit16 converts the result of processing expressed as an XML document to anobject in the data format handled by the program processing unit 12 andsends the object as a return value to the program processing unit 12.

FIG. 2 shows the functional configuration of a generation apparatus 20according to the embodiment. The generation apparatus 20 is implementedas one of the functions of the library processing unit 16 and convertsan object in a program to a structured document based on a schema. Indetail, the generation apparatus 20 generates mappings that representcorrespondences between individual properties included in an object in aprogram and the individual elements of a structured document generatedaccording to a schema. The generation apparatus 20 generates andoutputs, on the basis of the generated mappings, the structured documentbased on the schema, the structured document including the values of theindividual properties included in the object as the values of theelements corresponding to the properties.

An object represents, for example, an object and array data handled inan object-oriented program and serial array data used in, for example, aprogram written in PHP. A schema represents information that defines thehierarchical structure of a structured document. In the embodiment, aschema defines the hierarchical structure of an XML document that is anexemplary structured document. The generation apparatus 20 may convert asingle object to a single structured document or a plurality of objectsto a single structured document. The generation apparatus 20 may convertan object to a structured document other than an XML document (forexample, a Hypertext Markup Language (HTML) document).

The generation apparatus 20 includes a receiving unit 32, an object treegeneration unit 34, a document tree generation unit 36, a selection unit42, a conversion unit 44, and a transmission unit 46. In execution of aprogram, the receiving unit 32 receives, from the program processingunit 12, a function call, with an object as an argument, indicating toconvert the object to an XML document and transmit the XML document.

The object tree generation unit 34 generates a tree structure thatrepresents the hierarchical structure of the object in the function callreceived by the receiving unit 32 by assigning individual propertiesincluded in the object to the nodes of the tree structure. The documenttree generation unit 36 generates, from a schema that describes thehierarchical structure of an XML document stored in the schema storageunit 14, a tree structure that includes the individual elements of theXML document as the nodes of the tree structure. For example, thedocument tree generation unit 36 generates a tree structure in which thedefinitions of the individual elements of an XML document described in aschema are set as nodes, and the definitions of the number of childelements of the XML document described in the schema are set as edges.

The selection unit 42 selects, from mappings that associate theindividual properties included in the object with the individualelements of the XML document, a mapping that minimizes the conversioncost of converting the tree structure of the object to the treestructure of the XML document generated by the document tree generationunit 36. For example, the selection unit 42 includes a mappinggeneration unit 52, a calculation unit 54, and a mapping selection unit56.

The mapping generation unit 52 generates a plurality of mappings thatassociate the individual properties included in the object received bythe receiving unit 32 with the individual elements of the XML document.For each of the plurality of mappings generated by the mappinggeneration unit 52, the calculation unit 54 calculates, according to themapping, the conversion cost of converting the tree structure of theobject received by the receiving unit 32 to the tree structure of theXML document generated by the document tree generation unit 36. Themapping selection unit 56 selects, from the plurality of mappingsgenerated by the mapping generation unit 52, a mapping that minimizesthe conversion cost calculated by the calculation unit 54.

The conversion unit 44 converts, on the basis of the mapping selected bythe selection unit 42, the object to the XML document, which includesthe values of the individual properties of the object as the values ofthe corresponding elements. The transmission unit 46 transmits the XMLdocument output from the conversion unit 44.

FIG. 3 shows the process flow of the generation apparatus 20. Thereceiving unit 32 first receives, from the program processing unit 12, afunction call that indicates to convert an object in a program ofinterest to an XML document and transmit the XML document (step S101).

The object tree generation unit 34 retrieves an object included in thereceived function call as an argument. The object tree generation unit34 generates a tree structure that represents the hierarchical structureof the object by assigning individual properties included in theretrieved object to the nodes of the tree structure (step S102).

The document tree generation unit 36 retrieves a schema from the schemastorage unit 14 that describes the hierarchical structure of an XMLdocument to be output in response to the received function call.According to the retrieved schema, the document tree generation unit 36generates, from the schema, a tree structure that defines the structureof the XML document to be transmitted (step S103).

The selection unit 42 selects, from mappings that associate theindividual properties included in the object with the individualelements of the XML document, a mapping that minimizes the conversioncost of converting, according to the mapping, the tree structure of theobject to the tree structure of the XML document defined by the schema(step S104). In this case, the conversion cost of converting, accordingto a mapping, the tree structure of an object to the tree structure ofan XML document represents the cost of converting, according to themapping, the tree structure of the object to the tree structure of theXML document so that nodes corresponding to the individual properties ofthe object correspond to respective elements associated with theproperties.

The selection unit 42 finds a mapping that minimizes the conversion costamong a plurality of mappings. For example, the selection unit 42 findsa mapping that minimizes the conversion cost of converting the treestructure of the object to the tree structure of the XML document bysolving the tree editing problem shown in, for example, the Billearticle referred to above.

The conversion unit 44 converts, according to the mapping selected bythe selection unit 42, the object included in the received function callas an argument to the XML document defined by the schema, the XMLdocument including the values of the individual properties of the objectas the values of the corresponding elements (step S105). Thetransmission unit 46 transmits, to a Web service, a SOAP message thatincludes the XML document output from the conversion unit 44 (stepS106).

In the aforementioned manner, the generation apparatus 20 canautomatically generate a mapping between individual properties includedin an object in a program and a structured document defined by a schema(for example, an XML document). In this case, the generation apparatus20 may output a mapping selected by the selection unit 42 to theoutside. Such a generation apparatus 20 can provide a generated mappingso that the mapping is used by a known tool that converts an object toan XML document or the mapping is referred to in analysis ofcorrespondences between the properties of an object and the elements ofan XML document.

FIG. 4 shows an exemplary process performed in step S104 in FIG. 3. Forexample, in step S104 in FIG. 3, the selection unit 42 may perform stepsS111 to S113.

The mapping generation unit 52 first generates a plurality of mappingsthat associates individual properties included in an object with theindividual elements of an XML document (step S111). For each of theplurality of generated mappings, the calculation unit 54 calculates theminimum edit cost of converting, according to the mapping, the treestructure of the object to the tree structure of the XML document (stepS112). Then, the calculation unit 54 determines the calculated minimumedit cost as being the conversion cost of the mapping.

Edit operations for changing one tree structure (a first tree structure)so that the one tree structure has the same hierarchical structure asanother tree structure (a second tree structure) include, for example,renaming nodes, changing the sequence of nodes, and adding nodes. Thefirst tree structure can be converted to the same structure as thesecond tree structure by combining such edit operations. Edit operationcost is allocated to each of the edit operations. Many procedures forthe edit operations of converting the first tree structure to the samestructure as the second tree structure exist, and the total editoperation cost of the edit operations used in each of the proceduresvaries with the procedure.

Thus, for example, when the tree structure of an object is converted tothe tree structure of an XML document by performing, on the treestructure of the object, an edit process in which edit operations areperformed at least once, the edit operations including renaming nodes(properties), changing the sequence of a plurality of child nodes thatbelong to a common parent node, and adding a parent node for at leastone node, the calculation unit 54 may calculate the total of editoperation costs associated with the respective edit operations as theedit cost of the edit process. The calculation unit 54 may determine, asbeing the minimum edit cost, the edit cost of an edit process that isdetermined as minimizing edit cost among at least one edit process forconverting the tree structure of the object to the tree structure of theXML document.

In this case, since an XML document that includes all the properties inan object needs to be generated, the calculation unit 54 need notcalculate edit cost regarding an edit process that includes deletion ofnodes. The calculation unit 54 need not calculate edit cost regarding anedit process that is expected not to minimize edit cost, i.e., an editprocess the edit cost of which is expected in advance to be more than apredetermined value. This can reduce the amount of calculation in thecalculation unit 54.

The mapping selection unit 56 selects, from the plurality of mappingsgenerated by the mapping generation unit 52, a mapping that minimizesthe conversion cost calculated by the calculation unit 54 (step S113).In this manner, the selection unit 42 can find a mapping that minimizesthe conversion cost of converting the tree structure of an object to thetree structure of an XML document. In this case, the mapping generationunit 52 may omit processing for some mappings to rapidly completeselection of a mapping.

FIG. 5 shows an exemplary program written in PHP. In the program shownin FIG. 5, “new AgileSoapClient(”employee.wsdl“)” is a function callthat calls a program in a library, the program preparing fortransmission of a SOAP message

In the program shown in FIG. 5, “publishEmployee($person)” is anexemplary function call and an exemplary object included as an argumentprepared by the aforementioned program. The object is referred to by avariable $person and includes ‘name’, ‘firstname’, and ‘age’ as itsproperties. Moreover, ‘name’=‘Tatsubori’, ‘firstname’=‘Michiaki’, and‘age’=‘33’ are stored as the respective values of the properties.

The program processing unit 12 can transfer the function call (“newAgileSoapClient(“employee.wsdl”)”), which calls the program preparingfor transmission of the SOAP message, to the library processing unit 16by execution of the PHP program shown in FIG. 5 by a computer. Then, thelibrary processing unit 16, to which such function call has beentransferred, can convert, to an XML document, a function call that isseparately called and an object included in the function call as anargument (“publishEmployee($person)”) to add the XML document to theSOAP message.

FIGS. 6 and 7 exemplify the properties of the object, which has beenconverted to a tree structure, in the program shown in FIG. 5 and therespective values of the properties. FIG. 6 shows an example that isdescribed in XML. FIG. 7 shows an example that is describedschematically. When the object in the program shown in FIG. 5 is givento the object tree generation unit 34, the object tree generation unit34 generates a tree structure that includes three child nodes(‘name’=‘Tatsubori’, ‘firstname’=‘Michiaki’, and ‘age’=‘33’) directlybelow a parent node (anonymous), as shown in FIGS. 6 and 7.

FIG. 8 shows exemplary WSDL that defines a Web service. The WSDL shownin FIG. 8 defines a Web service called “PublishEmployeeServiceRequest”.When the library processing unit 16 has been called by the function callin the program shown in FIG. 5, the library processing unit 16 sends aSOAP message based on the definition by the WSDL shown in FIG. 8.

FIG. 9 shows an exemplary schema described in XML (an XML schema). FIG.10 shows the tree structure of an XML document defined by the schemashown in FIG. 9.

The schema shown in FIG. 9 defines the hierarchical structure of the XMLdocument to be added to the SOAP message to be sent to the Web servicedefined by the WSDL shown in FIG. 8. The XML document based on theschema shown in FIG. 9 includes elements the respective names of whichare defined as “Employee”, “person”, “name”, “age”, “first-name”,“middle-name”, and “last-name”. When the schema shown in FIG. 9 is givento the document tree generation unit 36, the document tree generationunit 36 generates the tree structure shown in FIG. 10.

The element “Employee” in the XML document defined by the schema shownin FIG. 9 is located at the root node of the tree structure, as shown inFIG. 10. The elements “person” are located as the child nodes of theelement “Employee”. In this case, the elements “person” are repetitivenodes. In an XML document, 0 to n (n is any integer equal to or morethan one) repetitive nodes may be provided.

The “name” element and the “age” element in the XML document defined bythe schema shown in FIG. 9 are located as the child nodes of each of the“person” elements, as shown in FIG. 10. In this case, each of the “name”element and the “age” element is a mandatory node that needs to occuronce in an XML document. An integer value is stored as the value of the“age” element.

The “first-name” element, the “middle-name” element, and the “last-name”element in the XML document defined by the schema shown in FIG. 9 arelocated as the child nodes of the “name” element, and a character stringis stored as the value of each of the “first-name” element, the“middle-name” element, and the “last-name” element, as shown in FIG. 10.In this case, each of the “first-name” element and the “last-name” is amandatory node that needs to occur once in an XML document. The“middle-name” element is an optional node that may be optionallyprovided in an XML document.

FIG. 11 shows an exemplary edit to convert the tree structure of theobject shown in FIG. 7 to the tree structure of the XML document shownin FIG. 10. FIG. 11 shows an example in which the ‘name’ property,‘firstname’ property, and ‘age’ property of the object are associatedrespectively with the “last-name” element, “first-name” element, and“age” element of the XML document by a mapping.

In this example, the calculation unit 54 may perform an edit operationof adding the “Employee” node as the parent node of the “anonymous” nodein the tree structure of the object. The calculation unit 54 may alsoperform an edit operation of renaming the “anonymous” node in the treestructure of the object the “person” node.

The calculation unit 54 may perform an edit operation of adding the“name” node as the parent node of each of the “name” node and the“firstname” node in the tree structure of the object. The calculationunit 54 may perform an edit operation of renaming the “name” node in thetree structure of the object the “last-name” node. The calculation unit54 may perform an edit operation of renaming the “firstname” node in thetree structure of the object the “first-name” node.

When the calculation unit 54 converts the tree structure of the objectto the tree structure of the XML document by performing, on the treestructure of the object, an edit process that includes such editoperations, for example, renaming nodes and adding parent nodes, thecalculation unit 54 calculates the total of edit operation costsassociated with the respective edit operations as the edit cost of theedit process. Then the calculation unit 54 calculates, as the minimumedit cost, the edit cost of an edit process that is determined asminimizing edit cost among at least one edit process for converting thetree structure of the object to the tree structure of the XML document.

FIG. 12 shows exemplary description of a mandatory node, an optionalnode, and a repetitive node. The calculation unit 54 may perform an editoperation of adding, to each of the nodes of the tree structure of theobject, type information (for example, “1”, “0 . . . 1”, and “0 . . . ”in FIG. 12) specifying a node type, for example, a mandatory node, anoptional node, or a repetitive node. For example, the calculation unit54 may determine the edit operation cost of such an edit operation asbeing lower than the edit operation cost of an edit operation of addinga node. For example, assuming that the edit operation cost of an editoperation of adding a node is one, the edit operation cost of an editoperation of adding type information may be set to zero.

When the calculation unit 54 renames a node, the calculation unit 54 maydetermine the distance (for example, the Levenshtein distance) betweenthe character string of a node name that has not been changed (i.e., thename of a property of an object) and the character string of the nodename (i.e., an element defined by a schema), which has been changed, asbeing edit operation cost associated with this edit operation. In thiscase, regarding an edit operation of a predetermined part, for example,a prefix that is provided at the beginning of a name, the calculationunit 54 may set the edit operation cost lower than the edit operationcost of an edit operation of another part.

Regarding an edit operation of interchanging child nodes that have thesame parent node, the calculation unit 54 may set the edit operationcost lower than the edit operation cost of an edit operation ofinterchanging nodes other than such child nodes. For example, regardingan edit operation of interchanging child nodes that have the same parentnode, the calculation unit 54 may set the edit operation cost to zero.Regarding an edit operation of generating a new node by combining aplurality of nodes at the same level, the calculation unit 54 may setthe edit cost lower than the edit cost of an edit operation of adding anew node.

When a mapping for each of the plurality of objects is generated, themapping selection unit 56 may store the mapping selected for the objectin a storage unit. Then, when a plurality of mappings with the same editcost exist for a certain object, the mapping selection unit 56 mayselect, from the plurality of mappings with the same edit cost, amapping that is the same as or similar to a corresponding mapping storedin the storage unit (i.e., a mapping selected in the past).

FIG. 13 shows an exemplary XML document that is converted from theobject shown in FIG. 5 on the basis of a mapping selected by theselection unit 42. In the aforementioned manner, the selection unit 42selects, from mappings that associate individual properties included inan object with the individual elements of an XML document, a mappingthat minimizes the conversion cost of converting the tree structure ofthe object to the tree structure of an XML document generated by thedocument tree generation unit 36.

In this example, the selection unit 42 selects a mapping that associatesthe ‘name’ property, ‘firstname’ property, and ‘age’ property of theobject respectively with the “last-name” element, “first-name” element,and “age” element of the XML document. As a result, when the objectshown in FIG. 5 has been given to the conversion unit 44, the conversionunit 44 can output the XML document shown in FIG. 13. Accordingly, theconversion unit 44 can convert a given object to an XML document basedon a schema.

FIG. 14 shows an exemplary tree structure of an object that includes anarray. FIG. 15 shows an exemplary tree structure of an XML document thatincludes repetitive elements.

In FIG. 14, a “memberList” node is an array node that has the individualelements of an array as its child nodes. In FIG. 15, “member” nodes arerepetitive nodes corresponding to repetitive elements repetition ofwhich is specified.

When the object given from the program includes the array, the objecttree generation unit 34 may generate the tree structure of the objectthat includes the array node having the individual elements of the arrayincluded in the object as its child nodes, as shown in FIG. 14. When theXML document defined by a schema includes the repetitive elements, thedocument tree generation unit 36 may generate the tree structure of theXML document that includes the repetitive elements, repetition of whichis specified in the XML document, as the repetitive nodes, as shown inFIG. 15.

When the object given from the program includes the array and the XMLdocument defined by the schema includes the repetitive elements, themapping generation unit 52 may generate a mapping that associates theproperties of the array included in the object with the repetitiveelements, repetition of which is specified in the XML document. That is,the mapping generation unit 52 may generate a mapping that associatesthe array node in the tree structure of the object with the repetitivenodes in the tree structure of the XML document. This allows the mappinggeneration unit 52 to generate a mapping that associates the propertiesof the array included in the object with the repetitive elements,repetition of which is specified in the XML document.

FIG. 16A shows an exemplary tree structure obtained by removing thechild nodes of the array node from the tree structure of the objectshown in FIG. 14. FIG. 16B shows an exemplary tree structure obtained byremoving the child nodes of the repetitive nodes from the tree structureof the XML document shown in FIG. 15. FIG. 17A shows an exemplary treestructure of a part on the low end side of the tree structure of theobject shown in FIG. 14, the top of the part being one of the childnodes of the array node. FIG. 17B shows an exemplary tree structure of apart on the low end side of the tree structure of the XML document shownin FIG. 15, the top of the part being one of the repetitive nodes.

When the object given from the program includes the array and the XMLdocument defined by the schema includes the repetitive elements, themapping generation unit 52 may generate a mapping that associates thenodes of the tree structure, shown in FIG. 16A, obtained by removing thechild nodes of the array node from the tree structure of the object withthe nodes of the tree structure, shown in FIG. 16B, obtained by removingthe child nodes of the repetitive nodes from the tree structure of theXML document.

In this case, when the array node in the tree structure of the objecthas been associated with the repetitive nodes in the tree structure ofthe XML document, the mapping generation unit 52 may generatecorrespondences between the child nodes of the array node and the childnodes of the repetitive nodes. That is, the mapping generation unit 52may generate correspondences between the tree structure of the part onthe low end side, shown in FIG. 17A, the top of the part being one ofthe child nodes of the array node, and the tree structure of the part onthe low end side, shown in FIG. 17B, the top of the part being one ofthe repetitive nodes. This allows the mapping generation unit 52 togenerate a mapping that associates the properties of each of theelements of the array included in the object with the individualelements on the low end side of each of the repetitive elements,repetition of which is specified in the XML document.

The document tree generation unit 36 may generate the tree structure ofan XML document that includes an optional element designated optional asan optional node and a mandatory element designated required as amandatory node. When a parent node, on the side of an object, thatincludes child nodes in the tree structure of the object is associatedwith a parent node, on the side of an XML document, that includesoptional nodes and mandatory nodes in the tree structure of the XMLdocument, the mapping generation unit 52 may preferentially associatethe child nodes in the tree structure of the object with the mandatorynodes. Thus, the mapping generation unit 52 can prevent a situation inwhich an XML document based on a schema cannot be generated because novalue is stored in a mandatory node in the XML document.

In a case where a mapping for each of the plurality of objects isgenerated, when the mapping generation unit 52 has generated, accordingto the description of one part of a program, a correspondence betweenone child node and a mandatory node, the mapping generation unit 52 maystore the correspondence in a history storage unit. Then, when thecorrespondence between the one child node and the mandatory node isstored in the history storage unit, according to the description ofanother part of the program, the mapping generation unit 52 mayassociate the one child node with the mandatory node, and associateanother child node with an optional node. Thus, the mapping generationunit 52 can perform consistent mapping for each of the plurality ofobjects in the program.

FIG. 18 shows an exemplary hardware configuration of a computer 1900according to the embodiment. The computer 1900 according to theembodiment includes a CPU peripheral section that includes a CPU 2000, aRAM 2020, a graphic controller 2075, and a display unit 2080 that areconnected to each other via a host controller 2082, an input-outputsection that includes a communication interface 2030, a hard disk drive2040, and a CD-ROM drive 2060 that are connected to the host controller2082 via an input-output controller 2084, and a legacy input-outputsection that includes a ROM 2010, a flexible disk drive 2050, and aninput-output chip 2070 that are connected to the I/O controller 2084.

The host controller 2082 connects the RAM 2020 to the CPU 2000 and thegraphic controller 2075, which access the RAM 2020 at a high transferrate. The CPU 2000 operates on the basis of programs stored in the ROM2010 and the RAM 2020 and controls individual components. The graphiccontroller 2075 obtains image data generated in a frame buffer providedin the RAM 2020 by, for example, the CPU 2000 and displays the imagedata on the display unit 2080. Alternatively, the graphic controller2075 may include a frame buffer for storing image data generated by, forexample, the CPU 2000.

The input-output controller 2084 connects the host controller 2082 tothe communication interface 2030, the hard disk drive 2040, and theCD-ROM drive 2060, which are relatively high-speed input-output units.The communication interface 2030 communicates with another apparatus viaa network. The hard disk drive 2040 stores programs and data used by theCPU 2000 in the computer 1900. The CD-ROM drive 2060 reads programs ordata from a CD-ROM 2095 and supplies the programs or data to the harddisk drive 2040 via the RAM 2020.

The ROM 2010, the flexible disk drive 2050, and the input-output chip2070, which are relatively low-speed input-output units, are connectedto the input-output controller 2084. The ROM 2010 stores a boot programthat is executed when the computer 1900 is activated and/or, forexample, programs that depend on the hardware of the computer 1900. Theflexible disk drive 2050 reads programs or data from a flexible disk2090 and supplies the programs or data to the hard disk drive 2040 viathe RAM 2020. The input-output chip 2070 connects the flexible diskdrive 2050 to the input-output controller 2084 and connects varioustypes of input-output units to the input-output controller 2084 via, forexample, a parallel port, a serial port, a keyboard port, and a mouseport.

Programs to be supplied to the hard disk drive 2040 via the RAM 2020 arestored in a recording medium, for example, the flexible disk 2090, theCD-ROM 2095, or an IC card, and supplied to users. The programs are readfrom the recording medium, installed in the hard disk drive 2040 in thecomputer 1900 via the RAM 2020, and executed in the CPU 2000.

Programs installed in the computer 1900 to cause the computer 1900 tofunction as the generation apparatus 20 include a receiving module, anobject tree generation module, a document tree generation module, aselection module, a conversion module, and a transmission module. Theprograms or modules work, for example, the CPU 2000 so as to cause thecomputer 1900 to function as the receiving unit 32, the object treegeneration unit 34, the document tree generation unit 36, the selectionunit 42, the conversion unit 44, and the transmission unit 46.

The information processing described in the programs is read by thecomputer 1900 to function as the receiving unit 32, the object treegeneration unit 34, the document tree generation unit 36, the selectionunit 42, the conversion unit 44, and the transmission unit 46, which areconcrete means in which software and the aforementioned various types ofhardware resources cooperate with each other. Then, calculation orprocessing of information specific to an intended use by the computer1900 according to the embodiment is implemented by the concrete means toconstruct the generation apparatus 20 specific to the intended use.

For example, when the computer 1900 communicates with, for example, anexternal apparatus, the CPU 2000 executes a communication program loadedinto the RAM 2020 to indicate to the communication interface 2030 toperform communication processing according to the content of processingdescribed in the communication program. The communication interface 2030reads, under the control of the CPU 2000, transmit data stored in, forexample, a transmit buffer area provided in a storage unit, such as theRAM 2020, the hard disk drive 2040, the flexible disk 2090, or theCD-ROM 2095, and transmits the transmit data to the network.

The communication interface 2030 further writes receive data receivedfrom the network to, for example, a receive buffer area provided in thestorage unit. The communication interface 2030 may perform transfer oftransmit and receive data from and to the storage unit by the directmemory access (DMA) method in this manner. Alternatively, the CPU 2000may read data from the storage unit or the communication interface 2030,which is a source, and then write the data to the communicationinterface 2030 or the storage unit, which is a destination, so as toperform transfer of transmit and receive data.

The CPU 2000 causes all or a necessary part of, for example, a file or adatabase stored in an external storage unit, such as the hard disk drive2040, the CD-ROM drive 2060 (the CD-ROM 2095), or the flexible diskdrive 2050 (the flexible disk 2090), to be read into the RAM 2020 by,for example, DMA transfer. The CPU 2000 performs various types ofprocessing on the data in the RAM 2020.

The CPU 2000 writes the data having been processed back to the externalstorage unit by, for example, DMA transfer. In such processing, sincethe RAM 2020 can be considered to temporarily store the content in theexternal storage unit, in the embodiment, the RAM 2020, the externalstorage unit, and the like are collectively called, for example, amemory, a storage, or a storage unit.

Various types of programs and various types of information such as data,tables, and a database in the embodiment are stored in such a storageunit and subjected to information processing. In this case, the CPU 2000may store a part of data in the RAM 2020 in a cache memory and performread and write operations on the cache memory. Even in such a case,since the cache memory undertakes some of the functions of the RAM 2020,in the embodiment, it is assumed that the cache memory is included inthe RAM 2020, a memory, and/or a storage unit, except wheredistinguished.

The CPU 2000 performs various types of processing on data read from theRAM 2020. The particular processing is specified by a string ofinstructions in a program, the various types of processing including,for example, various types of calculation, processing of information,condition determination, and retrieval and replacement of informationdescribed in the embodiment. Then, the CPU 2000 writes the processeddata back to the RAM 2020.

For example, when the CPU 2000 performs condition determination, the CPU2000 compares each of the various types of variables shown in theembodiment with another variable or a constant and determines whether acondition is satisfied. The condition includes, for example, thevariable is more than the other variable or the constant, the variableis less than the other variable or the constant, the variable is equalto or more than the other variable or the constant, the variable isequal to or less than the other variable or the constant, and thevariable is equal to the other variable or the constant. The processbranches to a different string of instructions, or a subroutine iscalled, after the condition is satisfied (or is not satisfied).

The CPU 2000 can search for information stored in, for example, a fileor a database in a storage unit. For example, when a plurality ofentries in each of which the attribute value of a first attribute isassociated with the attribute value of a second attribute are stored ina storage unit, the CPU 2000 can obtain the attribute value of thesecond attribute associated with the attribute value of the firstattribute that satisfies a predetermined condition by searching for anentry in which the attribute value of the first attribute satisfies thepredetermined condition in the plurality of entries stored in thestorage unit and reading the attribute value of the second attributestored in the entry.

The programs or modules, which have been described, may be stored in anexternal recording medium. Other than the flexible disk 2090 and theCD-ROM 2095, for example, an optical recording medium such as a DVD or aCD, a magneto-optical recording medium such as an MO, a tape medium, ora semiconductor memory such as an IC card may be used as a recordingmedium. A storage unit, such as a hard disk or a RAM, provided in aserver system connected to a private communication network or theInternet may be used as a recording medium, and the programs may besupplied to the computer 1900 via the network.

It should be noted that, regarding the execution sequence of processsteps in the apparatuses, the systems, the programs, and the methodsdescribed in the claims, the specification, and the drawings, theprograms, and the methods can typically be implemented with any sequenceof processes unless the output of a preceding process is used by afollowing process.

While the present invention has been described with reference to thepreferred embodiment, the technical scope of the present invention isnot limited to the description of the aforementioned embodiment. It isobvious to persons skilled in the art that various changes orimprovements can be made in the aforementioned embodiment. It is obviousfrom the description of the claims that the embodiment, in which suchchanges or improvements are made, is also covered by the scope of thepresent invention.

1. A generation apparatus that generates a mapping between individualproperties included in an object in a program and individual elements ofa structured document, the generation apparatus comprising: a selectionunit configured to select a mapping minimizing conversion cost ofconverting a tree structure of the object to a tree structure thatincludes the individual elements of the structured document as itsnodes; a document tree generation unit configured to generate a treestructure of the structured document and for determining that there is aparent node on a side of the object that includes child nodes in thetree structure of the object that is associated with a parent node on aside of the structured document that includes optional nodes andmandatory nodes in the tree structure of the structured document; and amapping generation unit that is configured for preferentiallyassociating the child nodes in the tree structure of the object with amandatory node when the parent node on the side of the object thatincludes the child nodes in the tree structure of the object isassociated with the parent node on the side of the structured documentthat includes the optional nodes and the mandatory nodes in the treestructure of the structured document.
 2. The generation apparatusaccording to claim 1, wherein the selection unit includes: a calculationunit that, for each of the mappings, is configured to calculate minimumedit cost of converting the tree structure of the object to the treestructure of the structured document, and sets the minimum edit cost asconversion cost of the mapping, and a mapping selection unit that isconfigured to select a mapping with minimum conversion cost calculatedby the calculation unit.
 3. The generation apparatus according to claim1, wherein the document tree generation unit is further configured togenerate a tree structure of the structured document from a schemadescribing hierarchical structure of the structured document, whereinthe selection unit selects a mapping minimizing conversion cost ofconverting the tree structure of the object to the tree structure of thestructured document generated by the document tree generation unit; andwherein the mapping is selected from the mappings which associate theindividual properties included in the object with the individualelements of the structured document.
 4. The generation apparatusaccording to claim 1, further comprising: a conversion unit configuredto convert the object to the structured document, which includes valuesof the individual properties of the object as values of thecorresponding elements, such conversion being on the basis of themapping selected by the selection unit.
 5. The generation apparatusaccording to claim 4, further comprising: a receiving unit configured toreceive a function call with the object as an argument, indicating toconvert the object to the structured document and transmit thestructured document; and a transmission unit configured to transmit thestructured document output by the conversion unit.
 6. The generationapparatus according to claim 5, wherein the mapping generation unit isfurther configured to generate a mapping that associates properties ofan array included in the object with repetitive elements repetition ofwhich is specified in the structured document.
 7. The generationapparatus according to claim 3, wherein the object tree generation unitis further configured to generate: a tree structure of the object thatincludes an array node having individual elements of an array includedin the object as its child nodes; a tree structure of the structureddocument that includes, as repetitive nodes, repetitive elementsrepetition of which is specified in the structured document; and amapping that associates the array node in the tree structure of theobject with the repetitive nodes in the tree structure of the structureddocument.
 8. The generation apparatus according to claim 7, wherein themapping generation unit is further configured to: generatecorrespondences between (i) nodes of a tree structure obtained byremoving the child nodes of the array node from the tree structure ofthe object and (ii) nodes of a tree structure obtained by removing childnodes of the repetitive nodes from the tree structure of the structureddocument, and generate correspondences between the child nodes of thearray node and the child nodes of the repetitive nodes when the arraynode in the tree structure of the object has been associated with therepetitive nodes in the tree structure of the structured document. 9.The generation apparatus according to claim 3, wherein the document treegeneration unit is further configured to generate a tree structure ofthe structured document that includes an optional element designatedoptional as an optional node and a mandatory element designated requiredas a mandatory node.
 10. The generation apparatus according to claim 9,wherein the mapping generation unit is configured to: store thecorrespondence in a history storage unit when having generated acorrespondence between one child node and the mandatory node accordingto description of one part of the program; and associate the one childnode with the mandatory node, and associate another child node with theoptional node when the correspondence between the one child node and themandatory node is stored in the history storage unit according todescription of another part of the program.
 11. The generation apparatusaccording to claim 2, wherein: the calculation unit is configured to:select, as the minimum edit cost, the edit cost of an edit process thatis determined as minimizing the edit cost among at least one editprocess for converting the tree structure of the object to the treestructure of the structured document when the tree structure of theobject is converted to the tree structure of the structured document byperforming, on the tree structure of the object, an edit process inwhich edit operations are performed at least once; and calculate totalof edit operation costs associated with the respective edit operationsas edit cost of the edit process, wherein the edit operations include:renaming the properties, changing sequence of a plurality of child nodesthat belong to a common parent node; and adding a parent node for atleast one node.
 12. A generation apparatus, comprising: a processordevice operatively coupled to a computer-readable storage medium, theprocessor device configured to: generate a mapping between individualproperties included in an object in a program and individual elements ofa structured document by: receiving a function call with the object asan argument indicating that the object is to be converted to thestructured document and the structured document transmitted; generatinga tree structure of the structured document that includes, as repetitivenodes, repetitive elements whose repetition is specified in thestructured document from a schema describing hierarchical structure ofthe structured document; preferentially associating the child nodes inthe tree structure of the object with a mandatory node when a parentnode on a side of the object, that includes child nodes in the treestructure of the object is associated with a parent node on a side ofthe structured document that includes the optional nodes and themandatory nodes in the tree structure of the structured document; andselecting a mapping minimizing conversion cost of converting the treestructure of the object to the tree structure of the structured documentgenerated by the document tree generation unit.
 13. A computer readablearticle of manufacture tangibly embodying computer readable instructionswhich, when executed, cause the computer to function as a generationapparatus according to claim
 1. 14. A generation method for generating amapping between individual properties included in an object in a programand individual elements of a structured document, the generation methodcomprising: selecting a mapping which minimizes cost of conversion of afirst tree structure to a second tree structure which includes theindividual elements of the structured document as its nodes; generatinga tree structure of the structured document for determining that thereis a parent node on a side of the object that includes child nodes inthe tree structure of the object that is associated with a parent nodeon a side of the structured document that includes optional nodes andmandatory nodes in the tree structure of the structured document; andpreferentially associating the child nodes in the tree structure of theobject with a mandatory node when a parent node on a side of the objectthat includes child nodes in the tree structure of the object isassociated with a parent node on a side of the structured document thatincludes the optional nodes and the mandatory nodes in the treestructure of the structured document.
 15. A computer readable article ofmanufacture tangibly embodying computer readable instructions which,when executed, cause the computer to carry out the steps of a methodaccording to claim
 14. 16. The generation method according to claim 14,wherein the selecting includes: calculating, for each of the mappings, aminimum edit cost of converting the tree structure of the object to thetree structure of the structured document; setting the minimum edit costas conversion cost of the mapping, and selecting a mapping with aminimum calculated conversion cost.
 17. The generation method accordingto claim 14, further comprising: generating a tree structure of thestructured document from a schema describing hierarchical structure ofthe structured document; and selecting a mapping minimizing a conversioncost of converting the tree structure of the object to the treestructure of the structured document generated by the document treegeneration unit, wherein the mapping is selected from mappings whichassociate the individual properties included in the object with theindividual elements of the structured document.
 18. The generationmethod according to claim 14, further comprising: converting the objectto the structured document, which includes values of the individualproperties of the object as values of the corresponding elements, suchconversion being on the basis of the mapping selected by the selectionunit.
 19. The generation method according to claim 18, furthercomprising: receiving a function call with the object as an argument,indicating to convert the object to the structured document and transmitthe structured document; and transmitting the structured document outputby the conversion unit.
 20. The generation apparatus according to claim12, wherein the selection unit includes: a calculation unit that, foreach of the mappings, is configured to calculate minimum edit cost ofconverting the tree structure of the object to the tree structure of thestructured document, and sets the minimum edit cost as conversion costof the mapping, and a mapping selection unit that is configured toselect a mapping with minimum conversion cost calculated by thecalculation unit.